package org.mclll.xwangplugin.web.controller;

import com.alibaba.fastjson.JSONObject;
import org.bukkit.Bukkit;
import org.eclipse.jetty.server.Request;
import org.mclll.xwangplugin.web.util.HttpServlet;
import org.mclll.xwangplugin.web.util.MyServlet;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@MyServlet("/onlinePeople")
public class OnlinePeople implements HttpServlet {

    @Override
    public String run(Request baseRequest, HttpServletRequest request, HttpServletResponse response) {
        JSONObject jsonRet = new JSONObject();
        jsonRet.fluentPut("count", Bukkit.getServer().getOnlinePlayers().size());
        return jsonRet.toJSONString();
    }
}
